#include "stdio.h"

int main()
{
    int arr[11][11] = { 0 };
    for (int i = 1; i <= 10; i++) {
        arr[i][1] = 1;
        arr[i][i] = 1;
    }
    for (int i = 3; i <= 10; i++) {
        for (int j = 2; j < 10; j++) {
            arr[i][j] = arr[i - 1][j - 1] + arr[i - 1][j];
        }
    }
    // 为了对齐,先计算最大数字的宽度
    int maxWidth = 1;
    for (int i = 1; i <= 10; i++) {
        for (int j = 1; j <= i; j++) {
            int temp = arr[i][j];
            int width = 1;
            while (temp >= 10) {
                width++;
                temp /= 10;
            }
            if (width > maxWidth)
                maxWidth = width;
        }
    }

    for (int i = 1; i <= 10; i++) {
        // 打印每行前的空格以居中对齐
        for (int space = 0; space < (10 - i) * (maxWidth + 1) / 2; space++) {
            printf(" ");
        }
        for (int j = 1; j <= i; j++) {
            printf("%*d ", maxWidth, arr[i][j]);
        }
        printf("\n");
    }
    return 0;
}